# load packages

pacman::p_load(tidyverse, scales, fixest, xtable, stargazer)

### table A.2 (heard of and witnessed crime in pool) ----

# load data
pools <- read_rds("data/survey.rds")

# calculate shares
results <- pools %>%
    summarise(heard_about_pool_crime = mean(hear_about_pool_crime, na.rm = T),
              experienced_pool_crime = mean(experience_pool_crime, na.rm = T),
              n = sum(!is.na(hear_about_pool_crime))) %>%
    mutate(ratio = heard_about_pool_crime/experienced_pool_crime)

# convert data frame to LaTeX table
output <- xtable(results, 
                 align = "ccccc",
                 caption = "Heard of and experienced crime in swimming pool", 
                 label = "tab:heard_about_crime")

print(output, 
      type = "latex", 
      include.rownames = F)

# clean
rm(list = ls())